<template>
  <el-row style="margin-top: 20px">
    <el-col :span="12">
      <el-page-header @back="goBack" title="返回" v-if="showBack"></el-page-header>
    </el-col>
    <!-- <el-col :span="12" >
      <el-dropdown style="float: right;cursor: pointer;">
        <span class="el-dropdown-link">
          {{ username }}
          <el-icon class="el-icon--right">
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="logout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </el-col> -->
  </el-row>
</template>

<script lang="ts" setup>
import { ref, reactive,watchEffect, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()

const showBack = ref(false)

const username = ref('')

onMounted(() => {
  username.value = sessionStorage.getItem('username')
})

// 或者使用 watchEffect 自动监听 route.query 的变化
watchEffect(() => {
  showBack.value = router.currentRoute.value.query.showBack
})
function logout() {
  router.push({ path: '/' })
}

function goBack() {
  // router.push({ path: router.currentRoute.value.query.from })
  router.go(-1)
}
</script>

<style lang="scss" scoped></style>
